#pragma once
#include<mysql_driver.h>
#include<mysql_connection.h>
#include<cppconn/statement.h>
#include<cppconn/prepared_statement.h>
#include<cppconn/exception.h>
#include<string>
#include"agreement.h"

class MMySql
{
private:
    /* data */
    //驱动管理器
    sql::mysql::MySQL_Driver *driver;
    //负责执行语句
    sql::Connection * con;
    // 数据库是否连接成功
    bool successConnection = false;

public:
    MMySql(const std::string host,const std::string username,
        const std::string userpassword,const std::string dateName,const unsigned int port=3306);
    ~MMySql();
    //改变在线状态
    void setOnline(int phone,bool flag);
    // 注册
    CloudDrive::MessageReturn enroll(int phone,std::string username,std::string userpass,std::string email);
    //登陆
    CloudDrive::MessageReturn Login(int phone,std::string userpass);
    //刷新在线人数
    CloudDrive::MesBack Refresh(int phone);
    //添加好友
    void addFriend(int user1,int user2);
    //删除好友
    CloudDrive::MessageReturn deletFriend(int user1,int user2);

};
